package LABS.lab8;

/**************************************************************
* Class HandShakes
* @author Jeff Thomas - Thomas007
* @vesion 1.0.0
* Date: 04.08.2008
* Copyright 2008, Jeff Thomas
***************************************************************/
import javax.swing.*;

public class HandShakes
{
	public static void main(String[] args)
	{
		int num = Integer.parseInt(JOptionPane.showInputDialog
                ("How many people are in the room?"));
		System.out.println("Handshakes: " + handshake(num));
	}
/**************************************************************
* handshake
* @return - Int of total number of handshakes
* Task:	1. Use base case of 1 to return 0 handshakes
*			2. Recursively call handshake with n-1 and add n-1
* Side Effects: None
***************************************************************/
	public static int handshake(int n)
	{
		if (n == 1)
			return 0;
		else
			return (n - 1) + handshake(n - 1);
	}
}
/**************************************************************
* I, Jeff Thomas, certify that each part of this program was
* written by me, except as noted within the code.
*
*						_________________________
***************************************************************/